<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <link rel="stylesheet" href="../../lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div>

    <form class="layui-form"  lay-filter="example" onsubmit="return false;" action="">
        <input type="hidden" name="pid"    placeholder="请输入pid" autocomplete="off" class="layui-input" value="0">

        <div class="layui-form-item">
            <label class="layui-form-label">栏目名称</label>
            <div class="layui-input-block">
                <input type="text" name="channelName" required  lay-verify="required" placeholder="请输入栏目名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <input type="hidden" name="roid"  placeholder="权限id" autocomplete="off" class="layui-input">
        <div class="layui-form-item">
            <label class="layui-form-label">权限角色</label>
            <div class="layui-input-block">
                <input type="text" name="rolename"  placeholder="请选择权限" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn"  lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="/js/jquery-1.12.1.min.js"></script>
<script src="/js/common.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;


        //监听提交
        form.on('submit(formDemo)', function (data) {
            let obj=api.saveChannel(data.field)
            layer.msg(obj.msg)
            if(obj.code===0){
                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);
            }else {
                return false;
            }
        });

    });
</script>
</body>
</html>